<?php
use_helper('I18N');
?>
<script type="text/javascript" language="javascript">
    var usdToMyr = "";
    $(function() {
        $("#btnSubmit").click(function(){
            $("#registerForm").submit();
        });
        $.populateDOB({
            dobYear : $("#dob_year")
            ,dobMonth : $("#dob_month")
            ,dobDay : $("#dob_day")
            ,dobFull : $("#dob")
        });
        $.validator.addMethod("noSpace", function(value, element) {
            return value.indexOf(" ") < 0 && value != "";
        }, "No space please and don't leave it empty");

        $.validator.addMethod("loginRegex", function(value, element) {
            return this.optional(element) || /^[a-z0-9\-\s\_]+$/i.test(value);
        }, "Username must contain only letters, numbers, or dashes.");

        $("#registerForm").validate({
        messages : {
            confirmPassword: {
                equalTo: "<?php echo __('Please enter the same password as above') ?>"
            },
            userName: {
                remote: "<?php echo __('User Name already in use') ?>."
            },
            fullname: {
                remote: "<?php echo __('Full Name already in use') ?>."
            }
        },
        rules : {
            "userName" : {
                required : true,
                noSpace: true,
                loginRegex: true,
                minlength : 4,
                remote: "/member/verifyUserName"
            },
            "userpassword" : {
                required : true,
                minlength : 6
            },
            "confirmPassword" : {
                required : true,
                minlength : 6,
                equalTo: "#userpassword"
            },
            /*"securityPassword" : {
                required : true,
                minlength : 6
            },
            "confirmSecurityPassword" : {
                required : true,
                minlength : 6,
                equalTo: "#securityPassword"
            },*/
            "leverage" : {
                required : true
            },
            "account_type" : {
                required : true
            },
            "deposit_amount" : {
                required : true
            },
            "fullname" : {
                required : true,
                minlength : 2
            },
            "dob" : {
                required : true
            },
            "address" : {
                required : true
            },
            "gender" : {
                required : true
            },
            "contactNumber" : {
                required : true
            },
            "email" : {
                required : true
                , email: true
            },
            /*"email2" : {
                required : true,
                equalTo: "#email"
            },
            "terms_cust_agreement" : {
                required : true
            },
            "terms_bis" : {
                required : true
            },
            "terms_risk" : {
                required : true
            },*/
            "terms_ecn" : {
                required : true
            },
            "risk_disclosure" : {
                required : true
            },
            "authorise" : {
                required : true
            }
        },
        submitHandler: function(form) {
            waiting();
            form.submit();
        },
        success: function(label) {
        }
    });
    }); // end function
</script>
<div class="row">
    <div class="col-md-12">
        <h2 class="page-title"><?php echo __("Open Live Account"); ?>
            <small></small>
        </h2>
    </div>
</div>
<div class="row">
    <div class="col-md-7">
        <section class="widget">
            <header>
                <h4>
                    <i class="icon-ok-sign"></i>
                    <?php echo __("Open Live Account"); ?>
                    <small></small>
                </h4>
            </header>
            <div class="body">
                <form class="form-horizontal label-left" method="post"
                      action="/register/doRegister"
                      data-validate="parsley"
                      id="registerForm" name="registerForm">
                    <input type="hidden" name="p" value="p">
                    <input type="hidden" name="id" value="<?php echo $mt4Id;?>">
                    <fieldset>
                        <legend class="section">
                        <?php echo __("Personal Information")?>
                        </legend>
                        <?php include_component('component', 'alert', array('param' => $sf_user->getAttribute(Globals::SESSION_DISTID, 0))) ?>
                        <div class="row">
                            <div class="col-sm-9">

                                <span class="help-block" style="color: #D2D2D2">
                                <?php echo __('Please choose a unique username for your account. Username accepts 3-32 characters, a-z, 0-9 and underscore (_) only.') ?>
                                </span>
                                <div class="control-group">
                                    <label class="control-label" for="userName">
                                    <?php echo __("User Name")?>
                                    </label>

                                    <div class="controls form-group">
                                        <input type="text" class="form-control" id="userName" name="userName">
                                    </div>
                                </div>
                                <span class="help-block" style="color: #D2D2D2">
                                <?php echo __('Please enter your password. Password accepts 4-32 characters, A-Z, a-z, 0-9 and underscore (_) only and must include at least one letter and one number. Password is also case sensitive.') ?>
                                </span>
                                <div class="control-group">
                                    <label class="control-label" for="userpassword">
                                    <?php echo __("Password")?>
                                    </label>

                                    <div class="controls form-group">
                                        <input type="password" class="form-control" id="userpassword" name="userpassword">
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="confirmPassword">
                                    <?php echo __("Confirm Password")?>
                                    </label>

                                    <div class="controls form-group">
                                        <input type="password" class="form-control" id="confirmPassword" name="confirmPassword">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </fieldset>

                    <fieldset>
                        <legend class="section">
                        <?php echo __("Trading Account Details")?>
                        </legend>
                        <div class="row">
                            <div class="col-sm-9">

                                <span class="help-block" style="color: #D2D2D2">
                                <?php echo __('Please note that the maximum leverage for ECN account is 1:100.') ?>
                                </span>
                                <div class="control-group">
                                    <label class="control-label" for="leverage">
                                    <?php echo __("Leverage")?>
                                    </label>

                                    <div class="controls form-group">
                                        <select name="leverage" class="inputbox" id="leverage">
                                            <option value="" selected="selected"></option>
                                            <option value="50">1:50</option>
                                            <option value="100">1:100</option>
                                            <option value="200">1:200</option>
                                            <option value="300">1:300</option>
                                            <option value="400">1:400</option>
                                            <option value="500">1:500</option>
                                        </select>
                                    </div>
                                </div>
                                <span class="help-block" style="color: #D2D2D2">
                                <?php echo __('Standard and ECN Account requires a minimum deposit of USD100 and USD500 respectively.') ?>
                                </span>
                                <div class="control-group">
                                    <label class="control-label" for="account_type">
                                    <?php echo __("Account Type")?>
                                    </label>

                                    <div class="controls form-group">
                                        <select name="account_type" class="inputbox" id="account_type">
                                            <option value="" selected="selected">Please Select</option>
                                            <option value="SocVAR">Standard Account</option>
                                            <option value="SocECN">ECN Account</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </fieldset>

                    <fieldset>
                        <legend class="section">
                        <?php echo __("Personal Information")?>
                        </legend>
                        <div class="row">
                            <div class="col-sm-9">

                                <div class="control-group">
                                    <label class="control-label" for="fullname">
                                    <?php echo __("Full Name")?>
                                    </label>

                                    <div class="controls form-group">
                                        <input name="fullname" id="fullname" class="form-control" type="text">
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label">
                                    <?php echo __("Date of Birth")?>
                                    </label>

                                    <div class="controls form-group">
                                        <select id="dob_year" style="width: 80px;"></select>
                                        <select id="dob_month" style="width: 80px;"></select>
                                        <select id="dob_day" style="width: 80px;"></select>
                                        <input name="dob" readonly="readonly" type="hidden" id="dob" class="bp_05"/>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="address">
                                    <?php echo __("Address")?>
                                    </label>

                                    <div class="controls form-group">
                                        <input name="address" class="form-control" value="" id="address" type="text">
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="address2">
                                    <?php echo __("Address")?> 2
                                    </label>

                                    <div class="controls form-group">
                                        <input name="address2" id="address2" class="form-control" value="" type="text">
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="city">
                                    <?php echo __("City / Town")?>
                                    </label>

                                    <div class="controls form-group">
                                        <input name="city" class="form-control" value="" id="city" type="text">
                                    </div>
                                </div>

                                <span class="help-block" style="color: #D2D2D2">
                                <?php echo __('Please enter \'0\' if postal code is not applicable in your country.') ?>
                                </span>
                                <div class="control-group">
                                    <label class="control-label" for="zip">
                                    <?php echo __("Zip / Postal Code")?>
                                    </label>

                                    <div class="controls form-group">
                                        <input name="zip" class="form-control" value="" id="zip" type="text">
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="state">
                                    <?php echo __("State / Province")?>
                                    </label>

                                    <div class="controls form-group">
                                        <input name="state" class="form-control" value="" id="state" type="text">
                                    </div>
                                </div>

                                <div class="control-group">
                                    <label class="control-label" for="country">
                                    <?php echo __("Country")?>
                                    </label>

                                    <div class="controls form-group">
                                        <?php include_component('component', 'countrySelectOption', array('countrySelected' => "Malaysia", 'countryName' => 'country', 'countryId' => 'country')) ?>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="gender">
                                    <?php echo __("Gender")?>
                                    </label>

                                    <div class="controls form-group">
                                        <select name="gender" class="inputbox" id="gender">
                                            <option value="" selected="selected">Please Select</option>
                                            <option value="M">Male</option>
                                            <option value="F">Female</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="contactNumber">
                                    <?php echo __("Contact Number")?>
                                    </label>

                                    <div class="controls form-group">
                                        <input name="contactNumber" id="contactNumber" class="form-control" type="text">
                                    </div>
                                </div>
                                <div class="control-group">
                                    <label class="control-label" for="email">
                                    <?php echo __("Email Address")?>
                                    </label>

                                    <div class="controls form-group">
                                        <input name="email" id="email" class="form-control" type="text">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </fieldset>

                    <fieldset>
                        <legend class="section">
                        <?php echo __("Acceptance")?>
                        </legend>
                        <div class="row">
                            <div class="col-sm-12">

                                <div class="control-group">
                                    <label class="control-label" for="fullname">
                                    <?php echo __("Leverage")?>
                                    </label>

                                    <div class="controls form-group">
                                       <p>Below are the contractural terms and agreements that you undertake as a Socrates FX client. Please check all the boxes below to acknowledge your acceptance, agreement and understanding of these terms.</p>
                                        <p><label><input name="terms_ecn" checked="checked" id="terms_ecn" class="checkbox" style="width: 50px; display: inline;"
                                                       type="checkbox">I agree to the Terms of Business</label></p>
                                        <p><input name="risk_disclosure" checked="checked" id="risk_disclosure" class="checkbox" style="width: 50px; display: inline;"
                                                       type="checkbox">I agree to the Risk Disclosure</p>
                                        <p><input name="authorise" checked="checked" id="authorise" class="checkbox" style="width: 50px; display: inline;"
                                                       type="checkbox">I hereby attest and certify that the above information is complete and accurate. I authorise Socrates FX to verify any or all of the submitted  information. This electronic signature has the same validity and effect as a signature affixed by hand.</p>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </fieldset>
                    <div class="form-actions">
                        <button type="button" id="btnSubmit" class="btn btn-danger"><?php echo __("Submit");?></button>
                        <a href="/member/summary" class="btn btn-default"><?php echo __("Cancel");?></a>
                    </div>
                </form>
            </div>
        </section>
    </div>
</div>